package org.pkg.jstools.preferences;

import org.eclipse.jface.preference.BooleanFieldEditor;
import org.eclipse.jface.preference.FieldEditorPreferencePage;
import org.eclipse.jface.preference.StringFieldEditor;
import org.eclipse.ui.IWorkbench;
import org.eclipse.ui.IWorkbenchPreferencePage;
import org.pkg.jstools.JSToolsActivator;


/**
 * This class represents a preference page that is contributed to the
 * Preferences dialog. By subclassing <samp>FieldEditorPreferencePage</samp>, we
 * can use the field support built into JFace that allows us to create a page
 * that is small and knows how to save, restore and apply itself.
 * <p>
 * This page is used to modify preferences only. They are stored in the
 * preference store that belongs to the main plug-in class. That way,
 * preferences can be accessed directly via the preference store.
 */

public class LintPreferencePage extends FieldEditorPreferencePage implements
		IWorkbenchPreferencePage {

	/**
	 * The default constructor for the JSLint preference page.
	 */
	public LintPreferencePage() {
		super(GRID);
		setPreferenceStore(JSToolsActivator.getDefault().getPreferenceStore());
		setDescription("See http://www.jslint.com/lint.html for details");
	}

	/**
	 * Creates the field editors. Field editors are abstractions of the common
	 * GUI blocks needed to manipulate various types of preferences. Each field
	 * editor knows how to save and restore itself.
	 */
	public void createFieldEditors() {
		
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_ADSAFE,"ADsafe", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_BITWISE,"Tolerate bitwise operators", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_BROWSER,"Assume a browser", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_CAP,"Tolerate HTML case", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_CONFUSION,"Tolerate type confusion", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_CONTINUE,"Tolerate continue", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_CSS,"Tolerate CSS workarounds", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_DEBUG,"Tolerate debugger statements", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_DEVEL,"Assume console, alert, ...", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_EQEQ,"Tolerate == and !=", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_ES5,"Tolerate ES5 syntax", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_EVIL,"Tolerate eval", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_FORIN,"Tolerate unfiltered for in", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_FRAGMENT,"Tolerate HTML fragments", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_NEWCAP,"Tolerate uncapitalized constructors", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_NODE,"Assume Node.js", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_NOMEN,"Tolerate dangling _ in identifiers", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_ON,"Tolerate HTML event handlers", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_PASSFAIL,"Stop on first error", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_PLUSPLUS,"Tolerate ++ and --", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_REGEXP,"Tolerate . and [^...]. in /RegExp/", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_RHINO,"Assume Rhino", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_SAFE,"Safe Subset", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_SLOPPY,"Tolerate missing 'use strict' pragma", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_SUB,"Tolerate inefficient subscripting", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_UNDEF,"Tolerate misordered definitions", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_UNPARAM,"Tolerate unused parameters", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_VARS,"Tolerate many var statements per function", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_WHITE,"Tolerate messy white space", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_WIDGET,"Assume a Yahoo Widget", getFieldEditorParent()));
		addField(new BooleanFieldEditor(PreferenceConstants.JSLINT_WINDOWS,"Assume Windows", getFieldEditorParent()));
		
		addField(new StringFieldEditor(PreferenceConstants.JSLINT_INDENT, "Strict white space indentation", getFieldEditorParent()));
		addField(new StringFieldEditor(PreferenceConstants.JSLINT_LINELEN, "Maximum line length", getFieldEditorParent()));
		addField(new StringFieldEditor(PreferenceConstants.JSLINT_ERRS, "Maximum number of errors", getFieldEditorParent()));
		//addField(new StringFieldEditor(PreferenceConstants.JSLINT_PREDEF, "An array of strings (, separated), the names of predefined global variable.", getFieldEditorParent()));
	}

	/*
	 * (non-Javadoc)
	 * 
	 * @see
	 * org.eclipse.ui.IWorkbenchPreferencePage#init(org.eclipse.ui.IWorkbench)
	 */
	public void init(IWorkbench workbench) {
	}

}